/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Simtest;
import simframe.simulation.*;

/**
 *
 * @author Steve Noble
 */
public class AgentY extends SimObject {

    static int name = 0;
    final int myName;
    // messages
     public Action  doMethodB(final AgentX x, final int val) {
            return new Action() { public void exec() {
                 methodB(x, val);
             }
         };
     }
     
    // Actions
    public static final Swarm.SwarmAction<AgentY> doOnce = new Swarm.SwarmAction<AgentY>() {
        public void exec(AgentY y) {
            y.doit();
        }
    };



     public AgentY() {
         myName = name++;
     }

     private void doit() {
     }
     
    private void methodB(AgentX x, int val) {
        // do stuff...
        System.out.print("Y" + Integer.toString(myName));
        System.out.print( " " + Time.toString(this.getTime()));
        
        System.out.print(" received " + Integer.toString(val));
        System.out.print( " sending " + Integer.toString(val - 1) + " --> X" + Integer.toString(x.myName) + "\n");
        x.action(x.doMethodA(val - 1));
    }
      
    @Override
    public boolean dead() {
       return false;
    }

    @Override
    public void reset() {
    }

}
